package com.autumn.util.excel;

import com.autumn.util.excel.column.ColumnInfo;

/**
 * 适配信息
 */
public abstract class AbstractAdapterInfo {

    public AbstractAdapterInfo() {
    }

    /**
     * 实例化 AdapterInfo 类新实例
     *
     * @param columnIndex 列索引
     * @param columnInfo  列信息
     */
    protected AbstractAdapterInfo(int columnIndex, ColumnInfo columnInfo) {
        this.columnIndex = columnIndex;
        this.columnInfo = columnInfo;
    }

    /**
     * 列索引
     */
    private int columnIndex;

    /**
     * 列信息
     */
    private ColumnInfo columnInfo;

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + columnIndex;
        result = prime * result + ((columnInfo == null) ? 0 : columnInfo.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof AbstractAdapterInfo)) {
            return false;
        }
        AbstractAdapterInfo other = (AbstractAdapterInfo) obj;
        if (columnIndex != other.getColumnIndex()) {
            return false;
        }
        if (columnInfo == null) {
            if (other.getColumnInfo() != null) {
                return false;
            }
        } else if (!columnInfo.equals(other.getColumnInfo())) {
            return false;
        }
        return true;
    }


    public int getColumnIndex() {
        return columnIndex;
    }

    public void setColumnIndex(int columnIndex) {
        this.columnIndex = columnIndex;
    }

    public ColumnInfo getColumnInfo() {
        return columnInfo;
    }

    public void setColumnInfo(ColumnInfo columnInfo) {
        this.columnInfo = columnInfo;
    }
}
